package com.zlict.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zlict.common.annotation.Log;
import com.zlict.common.core.controller.BaseController;
import com.zlict.common.core.domain.AjaxResult;
import com.zlict.common.enums.BusinessType;
import com.zlict.admin.domain.ProjectIntangibleWorkingHours;
import com.zlict.admin.service.IProjectIntangibleWorkingHoursService;
import com.zlict.common.utils.poi.ExcelUtil;
import com.zlict.common.core.page.TableDataInfo;

/**
 * 项目无形资产工时Controller
 * 
 * @author lqh
 * @date 2025-06-30
 */
@RestController
@RequestMapping("/admin/intangibleHours")
@RequiredArgsConstructor
public class ProjectIntangibleWorkingHoursController extends BaseController
{
    private final IProjectIntangibleWorkingHoursService projectIntangibleWorkingHoursService;

    /**
     * 查询项目无形资产工时列表
     */
    @PreAuthorize("@ss.hasPermi('admin:intangibleHours:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectIntangibleWorkingHours projectIntangibleWorkingHours)
    {
        startPage();
        List<ProjectIntangibleWorkingHours> list = projectIntangibleWorkingHoursService.selectProjectIntangibleWorkingHoursList(projectIntangibleWorkingHours);
        return getDataTable(list);
    }

    /**
     * 导出项目无形资产工时列表
     */
    @PreAuthorize("@ss.hasPermi('admin:intangibleHours:export')")
    @Log(title = "项目无形资产工时", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProjectIntangibleWorkingHours projectIntangibleWorkingHours)
    {
        List<ProjectIntangibleWorkingHours> list = projectIntangibleWorkingHoursService.selectProjectIntangibleWorkingHoursList(projectIntangibleWorkingHours);
        ExcelUtil<ProjectIntangibleWorkingHours> util = new ExcelUtil<ProjectIntangibleWorkingHours>(ProjectIntangibleWorkingHours.class);
        util.exportExcel(response, list, "项目无形资产工时数据");
    }

    /**
     * 获取项目无形资产工时详细信息
     */
    @PreAuthorize("@ss.hasPermi('admin:intangibleHours:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(projectIntangibleWorkingHoursService.selectProjectIntangibleWorkingHoursById(id));
    }

    /**
     * 新增项目无形资产工时
     */
    @PreAuthorize("@ss.hasPermi('admin:intangibleHours:add')")
    @Log(title = "项目无形资产工时", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectIntangibleWorkingHours projectIntangibleWorkingHours)
    {
        return toAjax(projectIntangibleWorkingHoursService.insertProjectIntangibleWorkingHours(projectIntangibleWorkingHours));
    }

    /**
     * 修改项目无形资产工时
     */
    @PreAuthorize("@ss.hasPermi('admin:intangibleHours:edit')")
    @Log(title = "项目无形资产工时", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectIntangibleWorkingHours projectIntangibleWorkingHours)
    {
        return toAjax(projectIntangibleWorkingHoursService.updateProjectIntangibleWorkingHours(projectIntangibleWorkingHours));
    }

    /**
     * 删除项目无形资产工时
     */
    @PreAuthorize("@ss.hasPermi('admin:intangibleHours:remove')")
    @Log(title = "项目无形资产工时", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(projectIntangibleWorkingHoursService.deleteProjectIntangibleWorkingHoursByIds(ids));
    }
}
